package web.ro.msg.gillardon.businesstripplanner;

import java.io.IOException;
import java.io.PrintWriter;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import backend.ro.msg.gillardon.dummyejb.HotelEJB;

/**
 * @author lorinczi address @ example.com.
 * @version 1.6 (current version number of program)
 * @since 2010-03-31 (the version of the package this class was first added to)
 */

public class AjaxServlet extends HttpServlet {

  /**
   * empty constructor
   */
  public AjaxServlet() {
    super();
  }

  @EJB
  HotelEJB hotel;

  private static final long serialVersionUID = 1L;

  /**
   * doGet
   *
   * @param req
   * @param resp
   */
  @Override
  protected void doGet(final HttpServletRequest req,
    final HttpServletResponse resp) throws ServletException,
    IOException {

    PrintWriter out = resp.getWriter();

    String city;
    city = req.getParameter("city");
    out.write(this.hotel.getHotels(city).toString());
  }

  /**
   * doPost
   *
   * @param req
   * @param resp
   */
  @Override
  protected void doPost(final HttpServletRequest req,
    final HttpServletResponse resp) throws ServletException,
    IOException {

    this.doGet(req, resp);
  }

}
